package com.cicc.beergamevirtualsimulationsystem.common.webSocket.handler.impl;

import com.cicc.beergamevirtualsimulationsystem.common.webSocket.handler.JsonMessageHandler;
import com.cicc.beergamevirtualsimulationsystem.common.webSocket.message.Impl.GamePauseJsonWebSocketMessage;
import com.cicc.beergamevirtualsimulationsystem.common.webSocket.message.Impl.GameResumeJsonWebSocketMessage;
import com.cicc.beergamevirtualsimulationsystem.common.webSocket.message.WebSocketMessageTypeEnum;
import com.cicc.beergamevirtualsimulationsystem.entity.RoomInfoManager;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

@Component
public class GameResumeJsonMessageHandler implements JsonMessageHandler<GameResumeJsonWebSocketMessage> {

    @Override
    public void handle(WebSocketSession session, GameResumeJsonWebSocketMessage message) {
        // TODO: 2022/7/13
        String roomId = session.getAttributes().get("roomId").toString();
        RoomInfoManager.continueCountdown(roomId);

    }

    @Override
    public String type() {
        return WebSocketMessageTypeEnum.GAME_RESUME.getValue();
    }

    @Override
    public Class<GameResumeJsonWebSocketMessage> getMessageClass() {
        return GameResumeJsonWebSocketMessage.class;
    }
}
